
  /**
 * @description 字典全局配置状态
 * @author 周浪 754032515@qq.com
 */
  import Cookies from 'js-cookie';
const state = {
    dict:Cookies.get("dict")?JSON.parse(Cookies.get("dict")): {}
};

const getters = {
    // 获取字典数据
    getDict:(state) => state.dict
};//----store.getter

const mutations = {
  // 设置字典
  setDict:(state, dictData) =>{
    if (dictData.dictType !== null && dictData.dictType !== "") {
        state.dict[ dictData.dictType]=dictData.dictData

    }
    Cookies.set("dict", JSON.stringify(state.dict));
  },
  // 删除字典
  removeDict:(state,key)=>{
    var bln = false;
    try {
      for (let i = 0; i < state.dict.length; i++) {
        if (state.dict[i].key == key) {
          state.dict.splice(i, 1);
          return true;
        }
      }
    } catch (e) {
      bln = false;
    }
    return bln;
  },
   // 清空字典
   cleanDict:()=> {
    state.dict = new Array();
  },
  // 初始字典
  initDict:() =>{
  }
};//----store.commit

const actions = {
}; //----store.dispatch

export default {
  getters,
  state,
  mutations,
  actions,
};
